package com.sidom.movieIndexer.mock;

import static org.mockito.Mockito.mock;

import org.springframework.beans.factory.FactoryBean;

/**
 * For more information see: http://javadevelopmentforthemasses.blogspot.com/2008/07/mocking-spring-tests.html
 */
@SuppressWarnings("unchecked")
public class MockFactory implements FactoryBean {

    private Class type;// the created object type

    public void setType(final Class type) {
        this.type = type;
    }

    @Override
    public Object getObject() throws Exception {
        return mock(type);
    }

    @Override
    public Class getObjectType() {
        return type;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
